/**
 *
 * @Author: baiyuxin
 * @Date: 2019-9-23
 * @Last Modified by:   baiyuxin
 * @Last Modified time: 2019-9-23 14:35:22
 */
import axios from '@/api/fetch';
import * as types from './types';
import SERVER from '@/api/server';

//

//查询全部列表（自定义数据过滤）@1
export const findPageDlr = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/getProjectPlan/dlr`, { params: _params, menuId: '-1' });
export const findPageOem = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/getProjectPlan/oem`, { params: _params, menuId: '-1' });
//查询待审核列表
export const findPageForFirstCheck = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/getProjectPlan/findPageForFirstCheck`, { params: _params, menuId: '-1' });
//查询待二级审核列表
export const findPageForLastCheck = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/getProjectPlan/findPageForLastCheck`, { params: _params, menuId: '-1' });

export const getDetails = (id, params) => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/${id}`, { params });

export const addData = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/`, params);

export const editData = (id, params) => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/${id}`, params);

// 计划作废
export const nullifyPlanById = id => axios.delete(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/nullifyPlanById/${id}`, { params: { id: id }, menuId: '-1' });
//计划撤回
export const porjectWithdraw = params => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/porjectWithdraw`, params);


//保存计划审核信息
export const checkSave = (id, params) => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/checkSave/${id}`, params);
//批量计划审核
export const batchCheck = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/check/batchCheck`, params);
//保存计划二级审核信息
export const checkSaveLast = (id, params) => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/checkSaveLast/${id}`, params);
//批量计划二级审核
export const batchCheckLast = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/check/batchCheckLast`, params);

//查询活动大类
export const getBigMarketType = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/paramdefinition/marketType/majorList`, { params: _params, menuId: '-1' });
//查询活动小类
export const getSmallMarketType = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/paramdefinition/marketType/majorList2`, { params: _params, menuId: '-1' });
//查询活动总结oem
export const getSummaryOemInquireList = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/getZJList`, { params: _params, menuId: '-1' });
//查询活动总结dlr
export const getSummaryDlrInquireList = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/getZJList/dlr`, { params: _params, menuId: '-1' });

//项目总结信息导出oem
// export const getSummaryOemInquireExcelList = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/export/excel`, params, { responseType: 'arraybuffer' });
export const getSummaryOemInquireExcelList = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/export/excel`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};

//项目总结信息导出dlr
// export const getSummaryOemInquireExcelList = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/export/excel`, params, { responseType: 'arraybuffer' });
export const getSummaryDlrInquireExcelList = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/export/excel/dlr`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};

//项目总结修改保存
export const updateCaseSummary = (params, id) => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/updateCaseSummary/${id}`, params);

//项目总结提报
export const handCaseSummary = (params, id) => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/handCaseSummary/${id}`, params);
//项目总结设置活动结束
export const finishCaseSummary = id => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/finishCaseSummary/${id}`);
//获取附件
export const selectListByBill = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/getListByBill`, { params });

//事业部意见保存
export const passCaseSummary = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectReviewLog/saveReviewLog`, params);
//修改项目总结状态为已通过、已驳回、已拒绝
export const updateCaseSummaryPass = (params, id) => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/updateCaseSummaryPass/${id}`, params);
//项目总结抽检已通过、已驳回、已拒绝
export const updateCheckCaseSummary = (params, id) => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/updateCheckCaseSummary/${id}`, params);
//批量通过
export const batchPassAll = ids => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/batchupdate/${ids}`);
//根据项目计划总结ID查询日志
export const getLogByPlanId = id => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectReviewLog/getByPlanId/${id}`);

// 项目计划-导出oem
export const exportExcel = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/plan/export/excel`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};
// 项目计划-导出dlr
export const exportExcelDlr = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/plan/export/excel/dlr`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};

// 项目审核-导出
export const exportPlanFirstCheckExcel = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/planFirstCheck/export/excel`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};

// 项目二级审核-导出
export const exportPlanLastCheckExcel = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/planLastCheck/export/excel`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};


//初始化项目抽检数量
export const getOemPlanCheckNum = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/getOemPlanCheckNum`, { params });
//初始化项目数量
export const getOemPlanNum = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectPlan/getOemPlanNum`, { params });
